#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int T,n,m,l,v;
struct node{
    int ds;
    int vc;
    int a;
}car[N];
map<int,int> p;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> T;
    while(T--){
        cin >> n >> m >> l >> v;
        for(int i=1;i<=n;i++){
            cin >> car[i].ds >> car[i].vc >> car[i].a;
        }
        for(int i=1;i<=m;i++){
            int u;
            cin >> u;
            p[u] = i;
        }

        int speedout = 0,Result = 0;
        for(int i=1;i<=n;i++){
            if(car[i].a == 0){
                if(car[i].vc > v){
                    speedout++;
                    car[i].is = true;
                    Result = 1;
                }
            }
        }
        cout << speedout << " " << Result << endl;
        for(int i=1;i<=n;i++){
            car[i].ds = car[i].vc = car[i].a = 0;
        }
    }
    return 0;
}
/*else{
                int vnum1 = v * v;
                if(car[i].a > 0){
                    if(car[i].vc >= v) speedout ++;
                    else{
                        int vnum2 = car[i].vc * car[i].vc;
                        int bbv =  vnum1 - vnum2;
                        double diss = bbv / (2*car[i].a);
                        bool flag = false;
                        int l = (int)car[i].dis_vv;
                        car[i].dis_vv += diss;
                        int r = (int)car[i].dis_vv;
                        for(int j=l;j<=r;j++){
                            if(p[j]!=0){
                                flag = true;
                                break;
                            }
                        }
                        if(flag){speedout++;}
                    }
                }
                else{
                    if(car[i].vc == v && p[car[i].ds] != 0){
                        speedout++;
                    }
                    else if(car[i].vc > v){
                        int vnum2 = car[i].vc * car[i].vc;
                        int bbv =  vnum2 - vnum1;
                        double diss = bbv / (2*car[i].a);

                        bool flag = false;
                        int l = (int)car[i].dis_vv;
                        car[i].dis_vv += diss;
                        int r = (int)car[i].dis_vv;
                        for(int j=l;j<=r;j++){
                            if(p[j]!=0){
                                flag = true;
                                break;
                            }
                        }
                        if(flag){speedout++;}
                    }else continue;
                }
            }*/
